import React, { Component } from 'react'
import './Header.css'
import context from '../../context'
export default class Header extends Component {
  static contextType = context
  render() {
    const { Add } = this.context
    return (
      <div className="todo-header">
        <input type="text" onKeyUp={(e)=>{
          if(e.keyCode!==13 || !e.target.value) return
          Add(e.target.value)
          e.target.value = ''
        }}/>
      </div>
    )
  }
}
